<?php

namespace App\Models;
use App\Observers\ArticleObserver;
use Illuminate\Database\Eloquent\SoftDeletes;


/**
 * App\Models\Article
 *
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Article newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Article newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Article query()
 * @mixin \Eloquent
 * @property-read \App\Models\User $user
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Article onlyTrashed()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Article withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Article withoutTrashed()
 */
class Article extends Base
{
	use SoftDeletes;
	protected $dates = ['deleted_at'];

	protected $guarded = ['_token'];
	// 查询文章对应的用户 反向关联 一对一
	public function user() {
		return $this->belongsTo(User::class);
	}

	// 观察者
	protected static function boot() {
		static::observe(ArticleObserver::class);
		parent::boot();
	}

}
